import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Iterator;

import javax.swing.JComponent;

public class DotComponent extends JComponent implements MouseListener {
	

	/*
	 for checking collection
	 dimension stuff
	 */
	public static final int finger_size =30;
	public static final int object_size = 60;
	public static final int table_size = 760;
	
	private DotGenerator dots;
	private int width=640;
	private int height=480;
	private float scale=1.0f;
	private static final int NUMBER_OF_DOTS=50;
	private int score=0;
	
	public DotComponent(){
		this.dots = new DotGenerator(width,height);
		for(int i = 0;i < NUMBER_OF_DOTS;i++){
			dots.generateDot();
			
			
			
			
		}
		
	}
	public void setSize(int w, int h){
		width = w;
		height = h;
		
	}
	public void paint(Graphics g){
		update(g);
		
		
	}
	public void update(Graphics g){
		
		Graphics2D g2 = (Graphics2D)g;
		g2.setColor(Color.BLACK);
		g2.fillRect(0, 0, width, height);
		
		g2.setColor(Color.YELLOW);
		g2.drawString("score: "+score,50,50);
		
		Iterator<Dot> iter = dots.gDots().iterator();
			while(iter.hasNext()){
				Dot carr = iter.next();
				g2.setColor(carr.gColor());
				g2.fillOval(carr.gX(), carr.gY(),carr.gSize(),carr.gSize());
				
			}
		
		
		
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		dots = new DotGenerator(width,height);
		for (int i = 0; i < NUMBER_OF_DOTS; i++){
			dots.generateDot();
			score++;
		}
		repaint();
		
	}
	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
